package com.tanner.mapreducedemo.patitioner;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @author zhang.t.c
 * @date 2021/8/2
 */
public class PhonePatitioner extends Partitioner<Text, FlowBean> {
    @Override
    public int getPartition(Text text, FlowBean flowBean, int numPartitions) {
        String phone = text.toString();
        String prePhone = phone.substring(0, 3);
        int patition;
        if ("136".equals(prePhone)) {
            patition = 0;
        } else if ("137".equals(prePhone)) {
            patition = 1;
        } else if ("138".equals(prePhone)) {
            patition = 2;
        } else if ("139".equals(prePhone)) {
            patition = 3;
        } else {
            patition = 4;
        }
        return patition;
    }
}
